package com.fare.taluo.vo.core.report;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.StringUtils;
/**
 * 收益报表导出上传页面传值VO
 * @author creator: xiangsf
 * @author modifior: xiangsf
 * @since 2012-12-22-下午5:51:29
 * @version v1.0
 */
public class EarningsExportVO implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -518154504042463863L;
	
	public static final String text_object_separator = ",";
	public static final String text_time_separator = ":";
	private Long[] ids;
	private Long creator;
	private String creatorName;
	private String hostid;
	private String timeDesc;
	private boolean enabled = false;
	private Integer grapDelayTime = 10;
	public EarningsExportVO(){
	}
	
	
	public Long[] getIds() {
		return ids;
	}


	public void setIds(Long[] ids) {
		this.ids = ids;
	}


	public String getHostid() {
		return hostid;
	}

	public void setHostid(String hostid) {
		this.hostid = hostid;
	}

	public String getTimeDesc() {
		return timeDesc;
	}

	public void setTimeDesc(String timeDesc) {
		this.timeDesc = timeDesc;
	}

	public String[] getSplitTime(){
		if(StringUtils.isNotEmpty(this.getTimeDesc())){
			return this.getTimeDesc().trim().split(text_object_separator);
		}
		return new String[0];
	}
	
	public boolean isEnabled() {
		return enabled;
	}


	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}


	public Integer getGrapDelayTime() {
		return grapDelayTime;
	}


	public void setGrapDelayTime(Integer grapDelayTime) {
		this.grapDelayTime = grapDelayTime;
	}


	public Long getCreator() {
		return creator;
	}


	public void setCreator(Long creator) {
		this.creator = creator;
	}


	public String getCreatorName() {
		return creatorName;
	}


	public void setCreatorName(String creatorName) {
		this.creatorName = creatorName;
	}


	public Date[] getTodayTime(){
		List<Date> dates = new ArrayList<Date>();
		List<String> list = new ArrayList<String>();
		Calendar cal = null;
		try{
			if(StringUtils.isNotEmpty(this.getTimeDesc())){
				String[] ss = getSplitTime();
				if(ss != null && ss.length > 0){
					for(String s : ss){
						if(StringUtils.isNotEmpty(s)){
							if(!list.contains(s)) list.add(s);
						}
					}
				}
			}
			for(String s : list){
				cal = Calendar.getInstance();
				cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(s.split(text_time_separator)[0]));
				cal.set(Calendar.MINUTE, Integer.valueOf(s.split(text_time_separator)[1]));
				cal.set(Calendar.SECOND, 0);
				
				dates.add(cal.getTime());
			}
		}finally{
			list = null;
			cal = null;
		}
		Collections.sort(dates);
		
		return dates.toArray(new Date[]{});
	}
}
